package 设计模式.代理模式.动态代理;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class MyTimeProxyInvocationHandler implements InvocationHandler
{
        private Object target;

    public MyTimeProxyInvocationHandler(Object target) {
        this.target = target;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {

        long start_time = System.currentTimeMillis();
        System.out.println("start time:----"+start_time);

        method.invoke(target,args);

        long end_time = System.currentTimeMillis();
        System.out.println("end_time:--------"+end_time);
        System.out.println("spend all time:-------"+(end_time-start_time)/1000+"s");

        return null;

    }
}
